<%@ page language="java"  pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>增加客户</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
     <LINK href="resource/css/admin.css" type="text/css" rel="stylesheet">
	 <script type="text/javascript" src="<%=basePath%>scripts/ckeditor/ckeditor.js"></script>
	 <script type="text/javascript">
	    function  addcheck(){
	         String.prototype.trim=function(){
                 return this.replace(/(^\s*)|(\s*$)/g, "");
            }
	       var  code=document.getElementById("code").value;
            if(code=="0"){
               alert("请选择添加客户名称类别");
               return false;
            }
            var  name=document.getElementById("name")
            var  namevalue=name.value.trim();
            if(namevalue==""){
                 alert("请填写客户名称");
                 return false;
             }
             if(namevalue.length>20){
                 alert("客户名称的长度应小于20");
                 return false;
             }
              var customid=document.getElementById("customid").value;
              if(customid==""){
              var  pic=document.getElementById("pic");
	        if(pic.value==''){
	          alert('请先选择客户logo图片');
	           return false;
	        }
	        if(!/(.gif)|(.png)|(.jpg)|(.jpeg)|(.ico)$/.exec(pic.value)){
			   alert('请上传图片格式');
			 return false;
			}
			}
			    
			
			  var  orderNum=document.getElementById("orderNum").value;
             if(orderNum==""){
                 alert("请填写序号");
                 return false;
             }else{
                if(isNaN(orderNum)){
                   alert("请输入数字");
                   return  false;
                }
             }
            return true;
            
	    }
	    function   showPic(){
	       var customid=document.getElementById("customid").value;
	       if( customid!=""){
	          document.getElementById("picspan").style.display="inline";
	       }
	    }
	 </script>
	 
  </head>
  
  <body onload="showPic()">
    <div align="center">
      <form  method="post" action="<%=basePath%>custom/addcustom.shtml" enctype="multipart/form-data" onsubmit="return addcheck()">
      <table>
      <tr>
      <td> 
          <input type="hidden" name="id" id="customid"   value="${custom.id}"/>
          客户类型:</td><td> <select name="custom.type" id="code">
                 <option value="0" >请选择添加客户的类别</option>
                <option value="1" ${custom.type eq 1?'selected' :''}>典型客户</option>
                <option value="2" ${custom.type eq 2?'selected' :''}>经典客户</option>
            </select>
            </td>
       </tr>
        <tr>
          <td>客户名称：</td>
          <td><input type="text" name="custom.name" id="name" value="${custom.name}"/></td>
        </tr>
         <tr>
          <td>客户(公司)logo：</td>
          <td><input type="file" name="imageFile" id="pic"/><font style="color:red"> 只支持.gif&nbsp;&nbsp;.png&nbsp;&nbsp; .jpg&nbsp;&nbsp;.jpeg&nbsp;&nbsp;.ico图片格式</font> &nbsp;&nbsp;&nbsp;&nbsp;<span id="picspan" style="display:none">原来的图片:<img align="middle" src="<%=basePath%>${custom.logoUrl}" height="60px;" width="60px;"/></span></td>
        </tr>
         <tr>
          <td>等级：</td>
          <td><input type="text" name="custom.orderNum" id="orderNum" value="${custom.orderNum}"/></td>
        </tr>
        <tr><td>简介：</td>
        <td><textarea id="content" name="custom.content" cols="28" rows="20">
          
           ${custom.content}
         </textarea></td></tr>
        <tr><td align="center" colspan="2"><input type="submit" value="保存" />&nbsp;&nbsp;<input type="reset" value="重置"></td></tr>
        </table>
        </form>
      </div>
        <script type="text/javascript">  
	//filebrowserUploadUrl ： 配置路径 Type 为不同类型文件在userfiles中存放的文件夹名
   					var editor = CKEDITOR.replace('content',{filebrowserUploadUrl : 'ckeditor/uploader?Type=File',   
									filebrowserImageUploadUrl : 'ckeditor/uploader?Type=Image',   
									filebrowserFlashUploadUrl : 'ckeditor/uploader?Type=Flash'  
   					});   
	</script>
  </body>
</html>
